﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;

namespace Twicko {
    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    public partial class UserStatus : UserControl {
        public UserStatus(string avatar, string user, string userName, string text) {
            InitializeComponent();

            BitmapImage logo = new BitmapImage();
            logo.BeginInit();
            logo.UriSource = new Uri(avatar);
            logo.EndInit();
            this.avatar.Source = logo;

            Hyperlink h2 = new Hyperlink(new Run("@"+user));
            h2.NavigateUri = new Uri("http://www.twitter.com/"+user);
            h2.RequestNavigate += UserStatus.openInBrowserEvent();

            this.user.Content = h2;//"@"+user;
            
            this.userName.Content = userName;



            this.text.Text = text;
        }


        //TODO Refatorar para classe utilitaria
        public static RequestNavigateEventHandler openInBrowserEvent() {
            return new RequestNavigateEventHandler(delegate(object sender, RequestNavigateEventArgs e) {
                Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
                e.Handled = true;
            });
        }
    }

}
